//
// RS Game Framework
// Copyright © 2009 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#ifndef RS_UNITTEST_TESTRUNNER_HPP
#define RS_UNITTEST_TESTRUNNER_HPP

#include "rs/unittest/TestReporter.hpp"
#include "rs/unittest/UnitTestForwards.hpp"
#include <vector>

namespace rs
{
    namespace unittest
    {
        class TestRunner : public TestReporter
        {
        public:
            
            typedef std::vector< TestReporter* > TestReporterContainer;
            
        public:
            
            TestRunner();
            
            virtual void Run();
            
            virtual void ReportSuiteStart(TestSuite const* suite);
            
            virtual void ReportSuiteEnd(TestSuite const* suite);
            
            virtual void ReportTestSuccees(TestCase const* test);
            
            virtual void ReportTestFailure(TestCase const* test, TestFailure const* failureDetails);
            
            virtual void ReportSummary(unsigned int totalTests, unsigned int failedTests);
            
            void AddTestReporter(TestReporter* testReporter);
            
            void RemoveTestReporter(TestReporter* testReporter);
            
        protected:
                        
            void RunTests();
            
        private:
            
            TestReporterContainer reporters_;
            RsSize totalTests_;
            RsSize totalFailedTests_;
        };
        
        
        inline TestRunner::TestRunner()
        : totalTests_(0),
          totalFailedTests_(0) {
        }
        
        inline void TestRunner::Run() {
            RunTests();
        }
    }
}

#endif // RS_UNITTEST_TESTRUNNER_HPP

